package com.xxchat.entity.enums;

import com.xxchat.utils.StringTools;
import lombok.Getter;

import java.util.Objects;

/**
 * @author Waicc
 */

@Getter
public enum GroupStatusEnum {
    NORMAL(1, "正常"),
    DISBAND(2, "解散");

    private final Integer status;
    private final String desc;

    GroupStatusEnum(Integer status, String desc) {
        this.status = status;
        this.desc = desc;
    }

    public static GroupStatusEnum getByStatus(Integer status) {
        for (GroupStatusEnum groupStatusEnum : GroupStatusEnum.values()) {
            if (Objects.equals(groupStatusEnum.getStatus(), status)) {
                return groupStatusEnum;
            }
        }
        return null;
    }

    public static GroupStatusEnum getByDesc(String desc) {
        try {
            if (StringTools.isEmpty(desc)) {
                return null;
            }
            return GroupStatusEnum.valueOf(desc.toUpperCase());
        } catch (Exception e) {
            return null;
        }
    }
}
